<!DOCTYPE HTML>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>alert</title>
  <script type="text/javascript">
    function rec() {
      var mychar = "I love JavaScript";
      alert(mychar);
    }
  </script>
</head>

<body>
  <input name="button" type="button" onClick="rec()" value="点击我，弹出对话框" />
</body>

</html>